package com.windern.algorithmlearning.mooc.recursion;

/**
 * 226. 翻转二叉树
 *
 * @author windern
 * @date 2020/11/24 07:48
 **/
public class InvertTree {

    public TreeNode invertTree(TreeNode root) {
        // 注意别忘写递归终止条件
        if (root == null) {
            return null;
        }

        invertTree(root.left);
        invertTree(root.right);

        TreeNode tmp = root.left;
        root.left = root.right;
        root.right = tmp;

        return root;
    }
}
